package com.stx.openeyes.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.stx.openeyes.R;
import com.stx.openeyes.model.Video;

import java.util.List;

public class NavigationItemAdapter extends BaseAdapter {
    private static final String TAG = "NavigationItemAdapter";
    private Context mContext;
    List<String> mItemList;

    public NavigationItemAdapter(Context mContext, List<String> itemList) {
        this.mContext = mContext;
        this.mItemList = itemList;
    }

    @Override
    public int getItemViewType(int position) {
        return 1;
    }

    @Override
    public int getCount() {
        return mItemList.size();
    }

    @Override
    public Object getItem(int position) {
        return mItemList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    private ViewHolder mHolder;

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        String itemListEntity = mItemList.get(position);
        mHolder = new ViewHolder();

        //设置布局
        convertView = LayoutInflater.from(mContext).inflate(R.layout.navigation_list_view_item, parent, false);
        if (convertView.getTag() instanceof ViewHolder) {
            mHolder = (ViewHolder) convertView.getTag();
        } else {
            mHolder.tvTitle = convertView.findViewById(R.id.title);
            convertView.setTag(mHolder);
        }
        //set data
        mHolder.tvTitle.setText(itemListEntity);
        return convertView;

    }

    static class ViewHolder {
        TextView tvTitle;
    }
}
